﻿//----------------------------------------------
//            NGUI: Next-Gen UI kit
// Copyright © 2011-2012 Tasharen Entertainment
//----------------------------------------------

using UnityEngine;
using UnityEditor;
using System;

/// <summary>
/// Inspector class used to edit UIMaterials.
/// </summary>

[CustomEditor(typeof(UIMaterial))]
public class UIMaterialInspector : Editor
{
	UIMaterial mMaterial;

	/// <summary>
	/// Register an Undo command with the Unity editor.
	/// </summary>

	void RegisterUndo () { NGUIEditorTools.RegisterUndo("UIMaterial Change", mMaterial); }
	
		/// <summary>
	/// Draw the inspector widget.
	/// </summary>

	public override void OnInspectorGUI ()
	{
		EditorGUIUtility.LookLikeControls(80f);
		mMaterial = target as UIMaterial;
		
		// Check to see if we can draw the UI3D's default properties to begin with
		if (OnDrawProperties())
		{
			// Draw all common properties next
			DrawCommonProperties();
		}
		
		OnDrawSrcPath();
	}

	protected void DrawCommonProperties ()
	{	
	}
	
	protected virtual bool OnDrawProperties () { return true; }
	
	protected void OnDrawSrcPath()
	{
		mMaterial.srcPath = EditorGUILayout.TextField("SrcPath:", mMaterial.srcPath);
		EditorGUILayout.Toggle("MustLoad", mMaterial.mustLoad);
	}
}